using System;
using System.Windows.Forms;

namespace PPPlotControl
{
	internal class WaitCursor : IDisposable
	{
		private Cursor cursor;

		private Control control;

		public WaitCursor()
		{
			control = null;
			cursor = Cursor.Current;
			Cursor.Current = Cursors.WaitCursor;
		}

		public WaitCursor(Control control)
		{
			this.control = control;
			cursor = control.Cursor;
			control.Cursor = Cursors.WaitCursor;
		}

		public void Dispose()
		{
			if (control != null)
			{
				control.Cursor = cursor;
			}
			else
			{
				Cursor.Current = cursor;
			}
		}
	}
}
